<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Sse测试文档</title>
</head>
<body>
<div>sse 测试</div>
<div id="result"></div>
</body>
</html>
<script>
    var source=new EventSource('http://localhost:8080/sse/subscribe?id=user2');
    source.onmessage=function (event) {
        text=document.getElementById('result').innerText;
        text+='\n'+event.data;
        document.getElementById('result').innerText=text;
    };
    source.onopen=function (event) {
        text=document.getElementById('result').innerText;
        text+='\n 开启:';
        console.log(event);
        document.getElementById('result').innerText=text;
    }
</script>